package test1225;
public class Test02 {
    public static void main(String[] args) {

        int[] arr = {1,2,3,4,5};

        // 返回最大值
        int max = m01(arr);
        System.out.println(max);

        // 返回最小值
        int min = m02(arr);
        System.out.println(min);

        // 返回平均值
        double avg = m03(arr);
        System.out.println(avg);

    }

    private static int m01(int[] arr) {
        int max = arr[0];
        for(int i=1;i<arr.length;i++){
            if(max<arr[i]){
                max = arr[i];
            }
        }
        return max;
    }
    private static int m02(int[] arr) {
        int min = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if(min>arr[i]) {
                min = arr[i];
            }
        }
        return min;
    }
    public static double m03(int[] arr) {
        int avg = arr[0];
        for (int i = 0; i < arr.length; i++) {
            avg += arr[i];
        }
        return avg / arr.length;
    }

}
